<template>
  <div id="app">
    <router-view/>
  </div>
</template>

<script>
    export default {
        name: 'App',

        //在钩子函数中增加监听刷新事件
        mounted() {
            window.addEventListener('unload', this.saveState);
        },
        methods: {
            saveState() {
                sessionStorage.setItem('state', JSON.stringify(this.$store.state.User)); //只能存字符串
            }
        }
    }
</script>
